import java.sql.Date;

/**
 * <p>
 * 创建日期：2021-07-28 23:29
 *
 * @author Hoppinging
 * @version 1.1
 * @since 1.0
 */
public class CURD {
    static JDBC jdbc;
    static {
        jdbc = new JDBC();
    }
    //Print
    public void print() {
        switch (jdbc.print()){
            case 0 -> System.out.println("System error");
            case 1 -> System.out.println("Print completed");
        }
    }
    //Create
    public void create(int ID, String name, double weight, String date) {
        switch (jdbc.add(new Cat(ID, name, weight, Date.valueOf(date)))) {
            case 0 -> System.out.println("System error");
            case 1 -> System.out.println("Repeated Aim");
            case 2 -> System.out.println("Create success");
            case 3 -> System.out.println("Create failed");
        }
        System.out.println("=============================================");
    }
    //Update
    public void update(int ID, int new_ID, String name, double weight, String date) {
        switch (jdbc.change(ID, new_ID, name, weight, Date.valueOf(date))){
            case 0 -> System.out.println("System error");
            case 1 -> System.out.println("Update success");
            case 2 -> System.out.println("Update failed");
            case 3 -> System.out.println("No such ID");
        }
        System.out.println("=============================================");
    }
    //Retrieve
    public void retrieve(String name) {
        switch (jdbc.find(name)){
            case 0 -> System.out.println("System error");
            case 1 -> System.out.println("Retrieve success");
            case 2 -> System.out.println("Retrieve failed");
        }
        System.out.println("=============================================");
    }
    public void retrieve(int ID) {
        switch (jdbc.find(ID)){
            case 0 -> System.out.println("System error");
            case 1 -> System.out.println("Retrieve success");
            case 2 -> System.out.println("Retrieve failed");
        }
        System.out.println("=============================================");
    }
    //Delete
    public void delete(int ID) {
        switch (jdbc.remove(ID)){
            case 0 -> System.out.println("System error");
            case 1 -> System.out.println("Delete success");
            case 2 -> System.out.println("Delete failed");
            case 3 -> System.out.println("No such ID");
        }
        System.out.println("=============================================");
    }
}
